<template>
  <div class="home">
    <el-container>
      <el-header>
        <el-row :gutter="20">
          <el-col :span="4"><img class="logo" src="../assets/logo.png" alt=""></el-col>
          <el-col :span="16"><h2>后台管理系统</h2></el-col>
          <el-col :span="4"><el-button class="logout" type="primary" link>退出登录</el-button></el-col>
        </el-row>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            active-text-color="#ffd04b"
            background-color="#545c64"
            class="el-menu-vertical-demo"
            default-active="2"
            text-color="#fff"
            router
          >
          <!-- router 开启路由模式，根据 index 的值进行跳转 -->
            <el-menu-item v-for="item in routeList" :index="item.path" :key="item.path">
              <span>{{item.meta.title}}</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { useRouter } from 'vue-router'
export default defineComponent({
  name: 'HomeView',
  setup() {
    const router = useRouter()
    const routeList = router.getRoutes().filter(item => item.meta.isShow)

    return {
      routeList
    }
  }
});
</script>

<style lang="less" scoped>
.logo{
  height: 80px;
}
h2{
  text-align: center;
  line-height: 80px;
  height: 80px;
  color: #fff;
}
.logout{
  text-align: center;
  line-height: 80px;
  height: 80px;
}
.el-header{
  height: 80px;
  background-color: #666;
}
.el-menu{
  height: calc(100vh - 80px);
}
</style>
